<template>
	<view class="page">
		<view :style="'padding-top:'+(demo.height+demo.top+10)+'px'">
			<head1 class="nav_top"
				:style="'height:' +  demo.height + 'px;' + 'padding-top:' + demo.top + 'px;padding-bottom:10px'"
				:nav="title">
			</head1>
		</view>

		<view class="reName" v-for="(item,index) in realList" :key="index" v-if="realList.length!=0">
			<block v-if="item.zslx_mc == '建造师'">
				<view class="tit">{{item.zslx_mc}}</view>
				<view class="reName_list">
					<text>证书等级：</text>
					<text>{{item.zsjb_mc}}</text>
				</view>
				<view class="reName_list">
					<text>发证日期：</text>
					<text>{{item.fzsj}}</text>
				</view>
				<view class="reName_list">
					<text>注册证书号：</text>
					<text>{{item.zczsh}}</text>
				</view>
				<view class="reName_list">
					<text>注册专业：</text>
					<text>{{item.zczy}}</text>
				</view>
				<view class="reName_list">
					<text>发证日期：</text>
					<text>{{item.fzsj}}</text>
				</view>
				<view class="reName_list">
					<text>证书有效期：</text>
					<text>{{item.zsyxqjssj == null ? '': item.zsyxqjssj}}</text>
				</view>
				<view class="reName_list" v-if="item.qymc">
					<text>所在单位：</text>
					<text>{{item.qymc}}</text>
				</view>
				<view class="btn" @click="certDetail(item)">
					<image src="../../static/icon/you_but.png" mode=""></image>
				</view>
			</block>
			<block v-else-if="item.zslx_mc == '三类人员'">
					<view class="tit">{{item.zslx_mc}}</view>
					<view class="reName_list">
						<text>职务：</text>
						<text>{{item.zsjb_mc}}</text>
					</view>
					<view class="reName_list">
						<text>证书号：</text>
						<text>{{item.zczsh}}</text>
					</view>
					<view class="reName_list">
						<text>发证日期：</text>
						<text>{{item.fzsj}}</text>
					</view>
					<view class="reName_list">
						<text>有效期：</text>
						<text>{{item.zsyxqjssj == null ? '': item.zsyxqjssj}}</text>
					</view>
					<view class="reName_list" v-if="item.qymc">
						<text>所在单位：</text>
						<text>{{item.qymc}}</text>
					</view>
					<view class="btn" @click="certDetail(item)">
						<image src="../../static/icon/you_but.png" mode=""></image>
					</view>
			</block>
			<block v-else-if="item.zslx_mc == '特种人员'">
				<view class="tit">{{item.zslx_mc}}</view>
				<view class="reName_list">
					<text>工种：</text>
					<text>{{item.zczy}}</text>
				</view>
				<view class="reName_list">
					<text>证书号：</text>
					<text>{{item.zczsh}}</text>
				</view>
				<view class="reName_list">
					<text>发证日期：</text>
					<text>{{item.fzsj}}</text>
				</view>
				<view class="reName_list">
					<text>有效期：</text>
					<text>{{item.zsyxqjssj == null ? '': item.zsyxqjssj}}</text>
				</view>
				<view class="reName_list">
					<text>首次取证单位：</text>
					<text>{{item.qymc}}</text>
				</view>
				<view class="reName_list" v-if="item.qymc">
					<text>下次复核时间：</text>
					<text>{{item.audittime}}</text>
				</view>
				<view class="btn" @click="certDetail(item)">
					<image src="../../static/icon/you_but.png" mode=""></image>
				</view>
			</block>
			<block v-else-if="item.zslx_mc == '岗位人员'">
				<view class="tit">{{item.zslx_mc}}</view>
				<view class="reName_list">
					<text>工种：</text>
					<text>{{item.zczy}}</text>
				</view>
				<view class="reName_list">
					<text>证书号：</text>
					<text>{{item.zczsh}}</text>
				</view>
				<view class="reName_list">
					<text>发证日期：</text>
					<text>{{item.fzsj}}</text>
				</view>
				<view class="reName_list">
					<text>有效期：</text>
					<text>{{item.zsyxqjssj == null ? '': item.zsyxqjssj}}</text>
				</view>
				<view class="btn" @click="certDetail(item)">
					<image src="../../static/icon/you_but.png" mode=""></image>
				</view>
			</block>
			<block v-else>
				<view class="tit">{{item.zslx_mc}}</view>
				<view class="reName_list">
					<text>证书号：</text>
					<text>{{item.zczsh}}</text>
				</view>
				<view class="reName_list">
					<text>等级：</text>
					<text>{{item.zsjb_mc}}</text>
				</view>
				<view class="reName_list">
					<text>证书专业：</text>
					<text>{{item.zczy}}</text>
				</view>
				<view class="reName_list">
					<text>发证日期：</text>
					<text>{{item.fzsj}}</text>
				</view>
				<view class="reName_list">
					<text>证书有效期：</text>
					<text>{{item.zsyxqjssj == null ? '': item.zsyxqjssj}}</text>
				</view>
				<view class="reName_list" v-if="item.qymc">
					<text>执业企业：</text>
					<text>{{item.qymc}}</text>
				</view>
				<view class="btn" @click="certDetail(item)">
					<image src="../../static/icon/you_but.png" mode=""></image>
				</view>
			</block>
		</view>
		<view v-if="realList.length==0" class="meishuju">
			{{meishuju}}
		</view>
	</view>
</template>

<script>
	import head1 from '../head/head.vue'
	export default {
		components: {
			head1
		},
		data() {
			return {
				title: '我的证书',
				isLoading: false,
				meishuju:'',
				demo: {
					top: '',
					height: ''
				},
				realName: {
					currentPage: '1',
					pageSize: '10',
					userId: '',
					sfzh: ''
				},
				realList: []

			}
		},
		computed: {
			isRealName() {
				return this.$store.state.isRealName
			},
			userid() {
				return this.$store.state.userId
			},
			newsfzh() {
				return this.$store.state.sfzh
			},
		},
		created() {

			const demo = uni.getMenuButtonBoundingClientRect()
			this.demo.top = demo.top
			this.demo.height = demo.height
			// 赋值userid 身份证号
			this.realName.userId = this.userid
			this.realName.sfzh = this.newsfzh
			this.getRealName(this.realName)
		},
		methods: {
			test() {
				this.$forceUpdate()
			
			},
			getRealName(data) {
				let _this = this
				uni.showLoading({
					title: '正在为您加载中....',
					success() {
						setTimeout(() => {
							_this.$myResquest.getRealName(data).then(res => {
								if (res.data.code == 200) {
									_this.realList = JSON.parse(res.data.data)
									for(var i=0;i<_this.realList.length;i++){
										if(_this.realList[i].zslx_mc=='三类人员'){
											console.log(_this.realList[i])
											}
									}
									if (_this.realList.length == 0) {
										_this.isLoading = true
										_this.meishuju='暂无数据'
									}
									uni.hideLoading()
								}
							})
						}, 1000)
					}
				})

			},
			// 证书详情
			certDetail(data){
				uni.navigateTo({
					url:'./certDetail?item='+data.ryzsxxid
				})
			}

		}
	}
</script>

<style lang="scss" scoped>
	.page {
		position: absolute;
		background: #f9f9f9;
		height: 100%;
		width: 100%;

		.reName {
			// width: 690rpx;
			width: 604rpx;
			background: #ffffff;
			border-radius: 10rpx;
			margin: 20rpx auto;
			position: relative;
			.reName_list {
				font-size: 24rpx;
				padding-left: 10rpx;
				line-height: 48rpx;

				:nth-child(1) {
					font-family: PingFang SC, PingFang SC-Medium;
					font-weight: 500;
					text-align: left;
					color: #999999;
				}
			}
			.blockMain{
				margin-top: 10rpx;
				width: 100%;
				background: pink;
			}
			.tit {
				font-size: 28rpx;
				font-family: PingFang SC, PingFang SC-Medium;
				font-weight: 500;
				text-align: center;
				color: #ffffff;
				line-height: 36rpx;
				background: #5cd1ce;
				padding: 8rpx 10rpx;
				// border-radius: 10rpx;
				margin-top: 20rpx;
			}
			.btn{
				position: absolute;
				width: 60rpx;
				height: 60rpx;
				top: 50%;
				right: 40rpx;
				border-radius: 50%;
				overflow: hidden;
				image{
					width: 100%;
					height: 100%;
				}
			}
		}

		.meishuju {
			width: 750rpx;
			text-align: center;
			height: 250rpx;
			line-height: 250rpx;
		}
	}

</style>
